package com.cskaoyan.javase.io._8serialization;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 反序列化的过程,依赖于ObjectInputStream
 * 要想对一个对象做序列化操作,进行持久化存储,就必须让该类实现接口java.io.Serializable
 *
 * @since 11:28
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        // ObjectInputStream(InputStream in)	创建从指定 InputStream 读取的 ObjectInputStream。
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("a.txt"));

        // Object	readObject()	从ObjectInputStream中读取还原一个对象。
        Student s = (Student) in.readObject();
        System.out.println(s);
    }
}
